<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
    <h:body>
		<ui:composition template="/admin/template.xhtml">		    			
		<p:panel header="Delegace">	
			<h:panelGrid columns="2">
				<p:panel header="Administrace delegací" style="min-width:500px;min-height: 1129px;">
					<h:panelGrid columns="1">	
							<p:panel header="Výběr zápasů" style="min-width:500px;">	
							<h:form>	
								<h:panelGrid columns="2">
									<h:panelGroup>
										<h:outputText value="Datum od: "/>
									</h:panelGroup>
									<h:panelGroup>						
								        <p:inputMask value="#{delegationBean.delegationDate}" mask="99.99.9999" style="width:70px"/>
								    </h:panelGroup>
								    <h:panelGroup>
										<h:outputText value="Datum to: "/>
									</h:panelGroup>
									<h:panelGroup>						
								        <p:inputMask value="#{delegationBean.delegtionDateTo}" mask="99.99.9999" style="width:70px"/>
								    </h:panelGroup>            			
			            				<p:commandButton value="Hledej"  actionListener="#{delegationBean.fillMatchListDate}" action="delegation.xhtml?faces-redirect=true" update=":detailDelegace,:delegatDialog"/>
			            			<h:panelGroup>
			            			</h:panelGroup>
			            		</h:panelGrid>
			            	</h:form>		
		            		</p:panel>
		            		<p:panel>            			
	            				<h:form id="detailDelegace" >
										<p:dataTable sortBy="#{player.competion.name}" var="player" value="#{delegationBean.matchList}" rowKey="#{player.id}"  selection="#{delegationBean.selectedMatch}" emptyMessage="Žádné zápasy nenalezeny" selectionMode="single" tableStyle="min-width:300px;" paginatorAlwaysVisible="false" paginatorPosition="bottom"  paginator="true" rows="15">
									        <p:column headerText="Soutěž" sortBy="#{player.competion.name}" >  
									            <h:outputText value="#{player.competion.name}" />  
									        </p:column>
									        <p:column headerText="Kolo" sortBy="#{player.round}" >  
									            <h:outputText value="#{player.round}" />  
									        </p:column>
									        <p:column headerText="Datum:" >  
									            <h:outputText value="#{player.datum}" />  
									        </p:column>
									        <p:column headerText="Čas:" >  
									            <h:outputText value="#{player.start}" />  
									        </p:column>
									        <p:column headerText="Domácí" >  
									            <h:outputText value="#{player.homeTeam.name}" />  
									        </p:column>
									        <p:column headerText="Hosté" >  
									            <h:outputText value="#{player.awayTeam.name}" />  
									        </p:column>
									        <p:column headerText="Delegát" >  
									            <h:outputText value="#{player.delegat}" />  
									        </p:column>
									        <p:column headerText="Spolujízda" >  
									            <h:outputText value="#{player.spolujizda}" />  
									        </p:column>
									        <p:column headerText="Hlavní rozhodčí" >  
									            <h:outputText value="#{player.mainReferee}" />  
									        </p:column>
									        <p:column headerText="AR1" >  
									            <h:outputText value="#{player.lineReferee}" />  
									        </p:column>
									        <p:column headerText="AR2" >  
									            <h:outputText value="#{player.lineRefereeTwo}" />  
									        </p:column>
									        <f:facet name="footer">  
								                	  <p:commandButton  icon="ui-icon-document" actionListener="#{delegationBean.dataForCompare}" value="upravit"  update=":delegatDialog" oncomplete="delegatDialog.show()"/>   
						       				</f:facet> 
							  	        </p:dataTable>
					  	        </h:form>
					  	        <p:dialog id="delegatDialog" header="Detail zápasu" widgetVar="delegatDialog" resizable="false" showEffect="clip" hideEffect="fold" position="10,10">
									<h:form>
											 <h:panelGrid columns="4" cellpadding="4">        	 		
								        	 		<h:outputText value="Datum : " />
								        	 		<p:inputMask value="#{delegationBean.selectedMatch.datum}" mask="99.99.9999" style="width:70px"/>
								        	 		<h:outputText value="Čas : " />
								        	 		<p:inputMask value="#{delegationBean.selectedMatch.start}" mask="99:99" style="width:50px"/>
								        	 		<h:outputText value="Delegát:" />
								        	 		<p:autoComplete value="#{delegationBean.selectedMatch.delegat}" completeMethod="#{delegationBean.completeDelegats}"/>  
								        	 		<h:outputText value="Spolujízda:" />
								        	 		<p:autoComplete value="#{delegationBean.selectedMatch.spolujizda}" completeMethod="#{delegationBean.completeDelegats}"/>
								        	 		<h:outputText value="Hlavní rozhodčí:" />
								        	 		<p:autoComplete value="#{delegationBean.selectedMatch.mainReferee}" completeMethod="#{delegationBean.completeReferees}"/> 
								        	 		<h:outputText value="AR1:" />
								        	 		<p:autoComplete value="#{delegationBean.selectedMatch.lineReferee}" completeMethod="#{delegationBean.completeReferees}"/>	
								        	 		<h:outputText value="AR2:" />
								        	 		<p:autoComplete value="#{delegationBean.selectedMatch.lineRefereeTwo}" completeMethod="#{delegationBean.completeReferees}"/>
								        	 		<h:outputText value="Poznámka:" />
								        	 		<p:autoComplete value="#{delegationBean.selectedMatch.poznamka}"/>	
								        	 		<h:outputText value="Zvýraznit změny: " />  
        											<p:selectBooleanCheckbox value="#{delegationBean.changes}" />	 
								        	 </h:panelGrid>	
							        	 <p:commandButton value="Uložit změny" actionListener="#{delegationBean.updateMatch}" update=":detailDelegace,:growl" oncomplete="delegatDialog.hide()"/>	
							        	 <p:commandButton value="Zrušit zvýraznění" actionListener="#{delegationBean.clearMatch}" update=":detailDelegace" oncomplete="delegatDialog.hide()"/>														
									</h:form>  
								</p:dialog>
					  	        
													 					  	                   		    
							</p:panel>  	  
					</h:panelGrid>
				</p:panel>
			</h:panelGrid>
		</p:panel>			
		</ui:composition>	
	</h:body>
</html>